package org.model.common.injector;

import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn;

import java.util.List;

/**
 * 自定义方法.
 *
 * @author zenghao
 * @date 2023/8/13
 */
public class CommonInjector extends DefaultSqlInjector {

    @Override
    public List<AbstractMethod> getMethodList(final Class<?> mapperClass, final TableInfo tableInfo) {
        List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);

        //当前class是CommonMapper的子类，则添加以下方法
        if (CommonMapper.class.isAssignableFrom(mapperClass)){
            methodList.add(new InsertBatchSomeColumn());
        }
        return methodList;
    }

}
